import Vue from 'vue';
import VueRouter from 'vue-router';
import HomeView from '../views/HomeView.vue';
import layout from '../components/layout/Index.vue'

Vue.use(VueRouter);

const routes = [
  {
    path: '/home',
    name: 'home',
    component: HomeView,
    meta: {
      title: '首页'
    }
  },
  {
    name: 'layout',
    path: '/',
    component: layout,
    redirect: '/home',
    children: [
      {
        name: 'about',
        path: 'about',
        component: () => import(/* webpackChunkName: "about" */ '../views/about.vue'),
        meta: {
          title: '关于我们'
        }
      }
    ]
  },
  // 这个404必须放到最后
  { path: "/:pathMatch(.*)", component: () => import("../views/404.vue") },
];

const router = new VueRouter({
  mode: 'history',
  base: process.env.VUE_APP_BASE_URL,
  routes,
});

export default router;
